package com.zxing.dubbo.gateway.config;

import com.alibaba.csp.sentinel.adapter.gateway.sc.callback.GatewayCallbackManager;
import com.zxing.dubbo.gateway.dto.ResponseData;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;

//@Configuration
public class SentinelConfig {

    public SentinelConfig(){
        ResponseData responseData = new ResponseData();
        responseData.setCode(499);
        responseData.setMessage("限流啦,请求太频繁");
        GatewayCallbackManager.setBlockHandler((serverWebExchange, throwable) -> ServerResponse.ok().body(Mono.just(responseData),ResponseData.class));
    }
}
